import Layout from '@/views/layout/Layout';

// 控制这系列页面的权限
const authData = {
  allOrder: ['crm:orderList:read'], // 渠道订单
  projectList: ['crm:project:read'], // 项目订单
  commerceOrder: ['crm:goodsOrder:read'], // 有赞订单
  mengliOrder: ['mengli:allOrder:', 'mengli:iPOrder:', 'mengli:emojiOrder:', 'mengli:commerceOrder:', 'mengli:channelOrder:'], // 萌力订单
  externalHarvest: ['crm:externalHarvest:read']// 外采额度申请
};
let pageAllAuth = [];
for (const key in authData) {
  pageAllAuth = pageAllAuth.concat(authData[key]);
}
// 订单
const orderRouter = [{
  path: '/orderPage',
  component: Layout,
  redirect: '/orderPage/allOrder',
  name: 'orderPage',
  meta: { title: '订单', icon: 'sidebar-order', authControl: pageAllAuth },
  children: [
    {
      path: 'allOrder',
      component: () => import('@/views/order/index'),
      name: 'allOrder',
      meta: {
        title: '渠道订单',
        keepAlive: true,
        isChange: true,
        headerBarShow: false,
        authControl: authData.allOrder
      }
    },
    {
      path: 'projectManageList',
      name: 'projectList',
      component: () => import('@/views/project/index'),
      meta: { title: '项目订单', keepAlive: true, isChange: true, headerBarShow: false, authControl: authData.projectList }
    },
    {
      path: 'projectChildList',
      name: 'projectChild',
      hidden: true,
      component: () => import('@/views/projectChild/index'),
      meta: { title: '项目渠道单', keepAlive: true, isChange: true, headerBarShow: false, activeMenu: '/orderPage/projectManageList' }
    },
    {
      path: 'commerceOrder',
      name: 'commerceOrder',
      component: () => import('@/views/commerce/productOrder'),
      meta: { title: '有赞订单', keepAlive: false, headerBarShow: false, authControl: authData.commerceOrder } // headerBarShow 为true显示头像
    },
    {
      path: 'commerceOrderFresh',
      name: 'commerceOrderFresh',
      hidden: true,
      component: () => import('@/views/commerce/productImport'),
      meta: { title: '订单更新', keepAlive: false, headerBarShow: true, activeMenu: '/orderPage/commerceOrder' } // headerBarShow 为true显示头像
    },
    {
      path: 'mengliOrderList',
      name: 'mengliOrder',
      component: () => import('@/views/mengliPlanet/mengliOrder/index'),
      meta: { title: '萌力订单', keepAlive: true, isChange: true, headerBarShow: false, authControl: authData.mengliOrder }
    },
    {
      path: 'externalHarvest',
      name: 'externalHarvest',
      component: () => import('@/views/externalHarvest/index'),
      meta: { title: '外采额度申请', keepAlive: true, isChange: true, headerBarShow: false, authControl: authData.externalHarvest }
    },
    /**
     * 内页
     */
    /** 项目管理 */
    {
      path: 'projectManageDetail/:id',
      name: 'projectDetail',
      component: () => import('@/views/project/detail'),
      hidden: true,
      meta: {
        title: '项目详情', headerBarShow: true, activeMenu: '/orderPage/projectManageList' }
    },
    // 项目管理-订单管理
    {
      path: 'projectOrderCreate',
      name: 'projectOrderCreate',
      component: () => import('@/views/project/detail/orderCreate'),
      hidden: true,
      meta: {
        title: '新增订单页', headerBarShow: true, activeMenu: '/orderPage/projectManageList' }
    },
    {
      path: 'projectOrderEdit/:id',
      name: 'projectOrderEdit',
      component: () => import('@/views/project/detail/orderCreate'),
      hidden: true,
      meta: {
        title: '订单编辑页', headerBarShow: true, activeMenu: '/orderPage/projectManageList' }
    },
    // 项目新增
    {
      path: 'projectManageCreate',
      name: 'createProject',
      component: () => import('@/views/project/create'),
      hidden: true,
      meta: {
        title: '新建项目', headerBarShow: true, activeMenu: '/orderPage/projectManageList' }
    },
    // 项目编辑
    {
      path: 'projectManageEdit/:id',
      name: 'editProject',
      component: () => import('@/views/project/create'),
      hidden: true,
      meta: {
        title: '编辑项目', headerBarShow: true, activeMenu: '/orderPage/projectManageList' }
    },
    // 子订单详情
    {
      path: 'projectChildDetail/:id',
      name: 'projectChildDetail',
      component: () => import('@/views/projectChild/detail'),
      hidden: true,
      meta: {
        title: '项目渠道单详情页', headerBarShow: true, activeMenu: '/orderPage/projectManageList' }
    },
    // 子订单新增
    {
      path: 'createProjectChild',
      name: 'createProjectChild',
      component: () => import('@/views/projectChild/create'),
      hidden: true,
      meta: {
        title: '新建项目渠道单', headerBarShow: true, activeMenu: '/orderPage/projectManageList' }
    },
    // 子订单编辑
    {
      path: 'editProjectChild/:id',
      name: 'editProjectChild',
      component: () => import('@/views/projectChild/create'),
      hidden: true,
      meta: {
        title: '编辑项目渠道单', headerBarShow: true, activeMenu: '/orderPage/projectManageList' }
    },
    /** 项目管理 end */
    /** 订单管理内页 start*/
    {
      path: 'ordercreate',
      component: () => import('@/views/order/create/create'),
      name: 'createOrder',
      meta: { title: '新增订单页', keepAlive: false, headerBarShow: true, activeMenu: '/orderPage/allOrder' },
      hidden: true
    },
    {
      path: 'batchcreate',
      component: () => import('@/views/order/create/createBatch'),
      name: 'batchcreate', // 批量增加订单
      meta: { title: '批量新增订单', keepAlive: false, headerBarShow: true, activeMenu: '/orderPage/allOrder' },
      hidden: true
    },
    {
      path: 'orderupload',
      component: () => import('@/views/order/upload/index'),
      name: 'orderupload',
      meta: { title: '文件上传', isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/orderPage/allOrder' },
      hidden: true
    },
    {
      path: 'orderedit/:orderId',
      component: () => import('@/views/order/create/create'),
      name: 'editOrder',
      meta: { title: '编辑订单页', isSeal: false, sealBillId: 0, active: 0, keepAlive: false, headerBarShow: true, activeMenu: '/orderPage/allOrder' },
      hidden: true
    },
    {
      path: 'orderdetail/:orderId',
      component: () => import('@/views/order/detail/index'),
      name: 'orderDetail',
      meta: { title: '订单详情', isSeal: false, keepAlive: false, headerBarShow: false, activeMenu: '/orderPage/allOrder' },
      hidden: true
    },
    /** 订单管理内页 end */
    /** 萌力订单内页 start */
    {
      path: 'mengliOrderAdd',
      name: 'mengliOrderAdd',
      hidden: true,
      component: () => import('@/views/mengliPlanet/mengliOrder/create/index'),
      meta: { activeMenu: '/orderPage/mengliOrderList', title: '新建订单', headerBarShow: true }
    },
    {
      path: 'mengliOrderEdit/:id',
      name: 'mengliOrderEdit',
      hidden: true,
      component: () => import('@/views/mengliPlanet/mengliOrder/create/index'),
      meta: { activeMenu: '/orderPage/mengliOrderList', title: '编辑订单', headerBarShow: true }
    },
    // 萌力订单创建和编辑 end
    {
      path: 'mengliOrderDetail/:id',
      name: 'mengliOrderDetail',
      hidden: true,
      component: () => import('@/views/mengliPlanet/mengliOrder/detail/index'),
      meta: { activeMenu: '/orderPage/mengliOrderList', title: '订单详情', headerBarShow: true }
    },
    // 电商售后单独路径
    {
      path: 'afterSaleAdd',
      name: 'afterSaleAdd',
      hidden: true,
      component: () => import('@/views/mengliPlanet/mengliOrder/create/index'),
      meta: { activeMenu: '/orderPage/mengliOrderList', title: '新建售后单', headerBarShow: true }
    },
    {
      path: 'afterSaleEdit/:id',
      name: 'afterSaleEdit',
      hidden: true,
      component: () => import('@/views/mengliPlanet/mengliOrder/create/index'),
      meta: { activeMenu: '/orderPage/mengliOrderList', title: '编辑售后单', headerBarShow: true }
    },
    {
      path: 'afterSaleDetail/:id',
      name: 'afterSaleDetail',
      hidden: true,
      component: () => import('@/views/mengliPlanet/mengliOrder/detail/index'),
      meta: { activeMenu: '/orderPage/mengliOrderList', title: '售后单详情', headerBarShow: true }
    },
    {
      path: 'externalHarvestCreate',
      name: 'externalHarvestCreate',
      hidden: true,
      component: () => import('@/views/externalHarvest/create'),
      meta: { activeMenu: '/orderPage/externalHarvest', title: '外采额度申请', headerBarShow: true }
    },
    {
      path: 'externalHarvestDetail',
      name: 'externalHarvestDetail',
      hidden: true,
      component: () => import('@/views/externalHarvest/detail'),
      meta: { activeMenu: '/orderPage/externalHarvest', title: '外采额度申请', headerBarShow: true }
    },
    {
      path: 'externalHarvestEdit/:id',
      name: 'externalHarvestEdit',
      hidden: true,
      component: () => import('@/views/externalHarvest/create'),
      meta: { activeMenu: '/orderPage/externalHarvest', title: '外采额度申请', headerBarShow: true }
    }
    /** 萌力订单内页 end */
  ]
}];
export default orderRouter;
